package com.quanyan.financialSystem.task;

import com.github.ltsopensource.core.domain.Job;
import com.github.ltsopensource.jobclient.JobClient;
import com.github.ltsopensource.jobclient.domain.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author xian-guo
 */

public class TimerTaskJob {

    private static final Logger LOGGER = LoggerFactory.getLogger(TimerTaskJob.class);

    @Autowired
    private JobClient jobClient;

    public void executeTask() {

        //统计当天所有场馆盈亏数据
        Job job = new Job();
        job.setTaskId("task_financial_branch_place");//每个任务必须指定唯一
        job.setParam("type", "typeA");//执行多个任务，传递参数
        job.setTaskTrackerNodeGroup("taskTracker_financial");//每个模块指定不同的名称，但同一个模块不同任务必须相同
        job.setNeedFeedback(true);
        job.setReplaceOnExist(true);        // 当任务队列中存在这个任务的时候，是否替换更新
        job.setCronExpression("0 00 03 * * ?");//设置指定时间触发，每天晚上点执行
        Response response = jobClient.submitJob(job);
        LOGGER.info("------任务是否提交成功----->>>>>>>>>>>>>>>>"+response);

    }

}
